//
// Created by 谢哲 on 2021/5/20.
//

#include <iostream>
#include <vector>
#include <deque>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;

    deque<pair<int,int>> qdata;
    for (int i=0;i<n;++i) {
        int a;
        cin >> a;
        if (i>=k) cout << qdata.front().second << "\n";
        while(!qdata.empty()&&qdata.back().second<=a) qdata.pop_back();
        while(!qdata.empty()&&qdata.front().first<=i-k) qdata.pop_front();
        qdata.emplace_back(make_pair(i, a));
    }
    cout << qdata.front().second;

    return 0;
}
